<template>
  <div class="listViewTop">
    <img class="bg" :src="playlist.coverImgUrl" alt="" />
    <div class="listViewTopnav">
      <div class="back" @click="$router.go(-1)">
        <svg class="icon" aria-hidden="true">
          <use xlink:href="#icon-arrowLeft"></use>
        </svg>
        <div class="title">歌单</div>
      </div>
      <div class="right">
        <svg class="icon sousuo" aria-hidden="true">
          <use xlink:href="#icon-sousuo"></use>
        </svg>
        <svg class="icon" aria-hidden="true">
          <use xlink:href="#icon-liebiao-dian"></use>
        </svg>
      </div>
    </div>
    <div class="content">
      <div class="contentLeft">
        <img :src="playlist.coverImgUrl" alt="" />
        <div class="count">
          <svg class="icon" aria-hidden="true">
            <use xlink:href="#icon-icon-"></use>
          </svg>
          <span>{{ changeCount(playlist.playCount) }}</span>
        </div>
      </div>
      <div class="contentRight">
        <h3>{{ playlist.name }}</h3>
        <div class="author" v-if="playlist.creator">
          <img class="header" :src="playlist.creator.avatarUrl" alt="" />
          <span>{{ playlist.creator.nickname }}</span>
        </div>
        <div class="description">
          {{ playlist.description }}
        </div>
      </div>
    </div>
    <div class="iconList">
      <div class="iconItem">
        <svg class="icon" aria-hidden="true">
          <use xlink:href="#icon-liaotian"></use>
        </svg>
        <span>{{ playlist.commentCount }}</span>
      </div>
      <div class="iconItem">
        <svg class="icon" aria-hidden="true">
          <use xlink:href="#icon-fenxiang"></use>
        </svg>
        <span>{{ playlist.shareCount }}</span>
      </div>
      <div class="iconItem">
        <svg class="icon" aria-hidden="true">
          <use xlink:href="#icon-xiazai"></use>
        </svg>
        <span>下载</span>
      </div>
      <div class="iconItem">
        <svg class="icon" aria-hidden="true">
          <use xlink:href="#icon-show_duoxuan"></use>
        </svg>
        <span>多选</span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "listViewTop",
  props: ["playlist"],
  mounted() {},
  methods: {
    changeCount(value) {
      if (value === undefined) {
        return "";
      }
      let result = value.toString();
      if (value >= 100000000) {
        result = `${(value / 100000000).toFixed(2)}亿`;
      } else if (value >= 10000) {
        result = `${(value / 10000).toFixed(2)}万`;
      }

      return result;
    },
  },
};
</script>
<style lang="less" scoped>
.listViewTop {
  width: 7.5rem;
  padding: 0 0.4rem;
  .bg {
    position: fixed;
    left: 0;
    top: 0;
    width: 7.5rem;
    height: auto;
    z-index: -1;
    filter: blur(40px);
  }
  .listViewTopnav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 1.2rem;
    font-size: 0.35rem;
    .icon {
      width: 0.6rem;
      height: 0.6rem;
      color: #fff;
      fill: #fff;
    }
    .title {
      margin-left: 0.4rem;
    }
    .sousuo {
      margin-right: 0.5rem;
    }
  }
  .back,
  .right {
    display: flex;
    color: #fff;
  }
  .content {
    display: flex;
    justify-content: space-between;
    padding: 0.6rem 0;
    .contentLeft {
      position: relative;
      img {
        width: 2.8rem;
        height: 2.8rem;
      }
      .count {
        position: absolute;
        right: 0.1rem;
        top: 0.1rem;
        font-size: 0.24rem;
        color: #aaa;
        display: flex;
        align-items: center;
        font-weight: 900;
        .icon {
          fill: #ccc;
        }
      }
    }
    .contentRight {
      width: 3.5rem;
      h3 {
        color: #fff;
      }
      .author {
        display: flex;
        margin: 0.2rem 0;
        img.header {
          width: 0.6rem;
          height: 0.6rem;
          border-radius: 0.3rem;
          margin-right: 0.2rem;
        }
        span {
          color: #ccc;
          font-size: 0.26rem;
        }
      }
      .description {
        font-size: 0.24rem;
        color: #ccc;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
      }
    }
  }
  .iconList {
    display: flex;
    justify-content: space-between;
    .iconItem {
      display: flex;
      flex-direction: column;
      align-items: center;
      .icon {
        width: 0.8rem;
        height: 0.6rem;
        fill: #fff;
      }
      span {
        font-size: 0.3rem;
        color: #fff;
        padding-top: 0.2rem;
      }
    }
  }
}
</style>